import numpy as np
from keras import models
from keras import layers
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.optimizers import SGD
from keras.utils import np_utils

from keras.utils.vis_utils import plot_model


def run():
    # 构建神经网络
    model = models.Sequential()
    model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))
    model.add(layers.MaxPooling2D(2, 2))
    model.add(layers.Conv2D(64, (3, 3), activation='relu'))
    model.add(layers.MaxPooling2D(2, 2))
    model.add(layers.Conv2D(64, (3, 3), activation='relu'))

    # 神经网络可视化
    #plot(model, to_file='model.png')
    plot_model(model, to_file='model.png')

if __name__ == '__main__':
    run()